﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Common;
using DataTool;
using workflowMVC.Models;
using DataTables;
namespace workflowMVC.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return RedirectToAction("ListNews");
        }
        public ActionResult ListNews()
        {
            ViewBag.datasource = Url.Action("NewsData");
            return View();
        }

        public ActionResult NewsData()
        {
            wfdbEntities db = new wfdbEntities();
            var data = db.NEWS.AsEnumerable().Select(x => new NewsModel
                {
                    date = x.Date.Value,
                    Title = x.Title
                });
            var cs = new DataTableParser<NewsModel>(Request, data.AsQueryable()).Parse();
            return Json(cs);
        }

        public ActionResult About()
        {
            return View();
        }
        public ActionResult Help()
        {
            return File("~/Views/Help/help.htm", "text/html");
        }
    }
}
